package com.lots.config;

import com.lots.interceptor.UserInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Autowired
    private UserInterceptor userInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(userInterceptor)
                .addPathPatterns(
                        "/user/favorite",
                        "/user/works",
                        "/user/stars",
                        "/user/favorite/{dishId}",
                        "/dish/isLiked/{id}",
                        "/dish/upload",
                        "/user/updateAvatar",
                        "/user/updateUserName",
                        "/activity/isReserved/{activityId}",
                        "/activity/reservedStatus/{activityId}"
                        );
//                ).excludePathPatterns(
//                        "/dish/hot",
//                        "/dish/new",
//                        "/dish/categories"
//                        );
    }
}
